package com.onlineMIS.action.shared.common;

import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Controller;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import com.onlineMIS.ORM.DAO.JspLoadResult;
import com.onlineMIS.action.BaseAction;
import com.onlineMIS.common.loggerLocal;
import com.opensymphony.xwork2.ActionContext;


/**
 * @describe: 此类用于描述jsp与后台交互的响应结果或者是一些公共的JSON请求
 * @author: pebble
 * @date: 2025.7.11
 */
@SuppressWarnings("serial")
@Controller
public class CommonJSONAction extends  BaseAction {
	
	private static final long serialVersionUID = 5951825438894923821L;
	
	private JSONObject jsonObject;
	private JSONArray jsonArray;
	private Map<String,Object> jsonMap = new HashMap<String, Object>();
	
	public JSONArray getJsonArray() {
		return jsonArray;
	}
	public void setJsonArray(JSONArray jsonArray) {
		this.jsonArray = jsonArray;
	}
	public JSONObject getJsonObject() {
		return jsonObject;
	}
	public void setJsonObject(JSONObject jsonObject) {
		this.jsonObject = jsonObject;
	}
	public Map<String, Object> getJsonMap() {
		return jsonMap;
	}
	public void setJsonMap(Map<String, Object> jsonMap) {
		this.jsonMap = jsonMap;
	}
	
	
	/**
	 * @describe:查询请求结果状态
	 * @return
	 */
	public String selectLoadResult() {
		loggerLocal.info("CommonJSONAction - selectLoadResult");
		JspLoadResult rersult = new JspLoadResult();
		
		try {			
			rersult = (JspLoadResult) ActionContext.getContext().getSession().get(JspLoadResult.LOAD_RESULT);
		} catch (Exception e) {
			loggerLocal.error(e);
		}
		try {
			jsonObject = JSONObject.fromObject(rersult);
		} catch (Exception e) {
			e.printStackTrace();
		}	
		return "successful";
	}
	
	
	/**
	 * @describe:重置jsp于后台交互响应结果
	 * @author: pebble
	 */
	public void resetJspResult() {
		ActionContext.getContext().getSession().put(JspLoadResult.LOAD_RESULT, new JspLoadResult(JspLoadResult.LOAD_RESULT_INIT, null));
		
		JspLoadResult jspLoadResult = (JspLoadResult) ActionContext.getContext().getSession().get(JspLoadResult.LOAD_RESULT);
		
		String aString = "";
	}
	
}
